#!/bin/bash

# 启动 PX4 SITL 模拟器
gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;cd /home/nvidia/demo_ws/PX4-Autopilot/Tools; ./sitl_multiple_run.sh 3; exec bash"

# 启动 MAVROS 节点
gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node  --remap __ns:=/drone_0 --ros-args -p fcu_url:=udp://:14540@localhost:14580 -p tgt_system:=1 -p gcs_url:=udp://@192.168.16.191; exec bash"
gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node --remap __ns:=/drone_1 --ros-args -p fcu_url:=udp://:14541@localhost:14581 -p tgt_system:=2; -p gcs_url:=udp://@192.168.16.191;exec bash"
gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node --remap __ns:=/drone_2 --ros-args -p fcu_url:=udp://:14542@localhost:14582 -p tgt_system:=3 ; -p gcs_url:=udp://@192.168.16.191; exec bash"


gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node  --remap __ns:=/drone_3 --ros-args -p fcu_url:=udp://:14543@localhost:14583 -p tgt_system:=4 -p gcs_url:=udp://@192.168.16.191; exec bash"
gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node --remap __ns:=/drone_4 --ros-args -p fcu_url:=udp://:14544@localhost:14584 -p tgt_system:=5; -p gcs_url:=udp://@192.168.16.191;exec bash"
gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node --remap __ns:=/drone_5 --ros-args -p fcu_url:=udp://:14545@localhost:14585 -p tgt_system:=6 ; -p gcs_url:=udp://@192.168.16.191; exec bash"

gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node  --remap __ns:=/drone_6 --ros-args -p fcu_url:=udp://:14546@localhost:14586 -p tgt_system:=7 -p gcs_url:=udp://@192.168.16.191; exec bash"
gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node --remap __ns:=/drone_7 --ros-args -p fcu_url:=udp://:14547@localhost:14587 -p tgt_system:=8; -p gcs_url:=udp://@192.168.16.191;exec bash"
gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node --remap __ns:=/drone_8 --ros-args -p fcu_url:=udp://:14548@localhost:14588 -p tgt_system:=9 ; -p gcs_url:=udp://@192.168.16.191; exec bash"

gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node  --remap __ns:=/drone_9 --ros-args -p fcu_url:=udp://:14549@localhost:14589 -p tgt_system:=10 -p gcs_url:=udp://@192.168.16.191; exec bash"
gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node --remap __ns:=/drone_10 --ros-args -p fcu_url:=udp://:14550@localhost:14590 -p tgt_system:=11; -p gcs_url:=udp://@192.168.16.191;exec bash"
gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node --remap __ns:=/drone_11 --ros-args -p fcu_url:=udp://:14551@localhost:14591 -p tgt_system:=12 ; -p gcs_url:=udp://@192.168.16.191; exec bash"

gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node  --remap __ns:=/drone_12 --ros-args -p fcu_url:=udp://:14552@localhost:14592 -p tgt_system:=13 -p gcs_url:=udp://@192.168.16.191; exec bash"
gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node --remap __ns:=/drone_13 --ros-args -p fcu_url:=udp://:14553@localhost:14593 -p tgt_system:=14; -p gcs_url:=udp://@192.168.16.191;exec bash"
gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node --remap __ns:=/drone_14 --ros-args -p fcu_url:=udp://:14554@localhost:14594 -p tgt_system:=15 ; -p gcs_url:=udp://@192.168.16.191; exec bash"
gnome-terminal -- bash -c "export PX4_SIM_HOST_ADDR=192.168.16.25;source /opt/ros/foxy/setup.bash; ros2 run mavros mavros_node  --remap __ns:=/drone_15 --ros-args -p fcu_url:=udp://:14555@localhost:14595 -p tgt_system:=16 -p gcs_url:=udp://@192.168.16.191; exec bash"